﻿/*********************************************************************
 *
 *                             NOTICE
 *               COPYRIGHT (c) 2012 Panoscopix Software, Inc.
 *                UNPUBLISHED - ALL RIGHTS RESERVED
 * 
 *      This program is confidential, proprietary, and a trade
 *   secret of Panoscopix Software, Inc. The receipt or possession of
 *     this program does not convey any rights to reproduce or
 *      disclose its contents, or to manufacture, use, or sell
 *       anything that it may describe, in whole or in part, 
 *   without the specific written consent of Panoscopix Software, Inc.
 *
 * Implementation of a Countdown Latch lock.
 * 
 *******************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace FileSystem.Utility
{
    class LatchLock
    {
        private ManualResetEvent latch;

        public LatchLock()
        {
            latch = new ManualResetEvent(false);  //initially not signalled.
        }

        public void countDown()
        {
            latch.Set();
        }

        public void await()
        {
            try
            {
                latch.WaitOne();
            }
            catch (Exception )
            {
                //ignore.
            }
        }
    }
}
